import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    port: 8081,
    host: true,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:8082',
        changeOrigin: true,
      },
      '/run': {
        target: 'http://127.0.0.1:8082',
        changeOrigin: true,
        ws: true, // 支持 WebSocket 代理
      },
      '/screenshots': {
        target: 'http://127.0.0.1:8082',
        changeOrigin: true,
      },
      '/run_artifacts': {
        target: 'http://127.0.0.1:8082',
        changeOrigin: true,
      }
    }
  },
  build: {
    outDir: 'dist',
    sourcemap: true,
  },
  define: {
    'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
  }
})
